﻿<UserControl x:Class="BaMusaSoft.RPS.View.ClaimView"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:wpfExtended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
             xmlns:local="clr-namespace:BaMusaSoft.RPS.View" x:Name="parentView"
			 Loaded="ViewLoaded"
			 mc:Ignorable="d" FlowDirection="RightToLeft" d:DesignWidth="626.387">
	<UserControl.Resources>
		<ContextMenu x:Key="gridRowContextMenu" >
			<MenuItem Header="حذف" Command="{Binding DeleteClaimDetailCommand}" 
					  CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
		</ContextMenu>
	</UserControl.Resources>
	<UserControl.InputBindings>
		<KeyBinding Key="N" Modifiers="Control" Command="{Binding AddNewCommand}"/>
		<KeyBinding Key="F2" Modifiers="Control" Command="{Binding ElementName=parentView, Path = AddCustomerCommand}"/>
		<KeyBinding Key="F3" Modifiers="Control" Command="{Binding AddOutboxCommand}"/>
		<KeyBinding Key="F4" Modifiers="Control" Command="{Binding AddDetailsCommand}"/>
	</UserControl.InputBindings>
	<Grid UIElement.PreviewKeyDown="Grid_KeyDown">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			<Grid x:Name="Header" Grid.Row="0" Margin="0,0,0,10">
				<Grid.RowDefinitions>
					<RowDefinition />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<StackPanel Grid.Row="0" Orientation="Horizontal">
				<Button Margin="5" Command="{Binding AddNewCommand}" Style="{StaticResource AddNewButtonStyle}"/>
				<Button  HorizontalAlignment="Left"  Margin="5" 
						Command="{Binding SaveCommand}" Style="{StaticResource SaveButtonStyle}" />
				<Button  HorizontalAlignment="Left" Margin="5" Style="{StaticResource PrintButtonStyle}"
						Command="{Binding PrintCommand}" Content="{DynamicResource PrintImage}"/>
					<Button Content="Button" HorizontalAlignment="Left" Height="36" Margin="5" Width="61"/>
				
			</StackPanel>
				<Border Grid.Row="0"  Grid.Column="1" BorderThickness="3" CornerRadius="2" Padding="5" >
					<Border.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFB2B2B2" Offset="0"/>
							<GradientStop Color="#FF6D84AE" Offset="1"/>
						</LinearGradientBrush>
					</Border.Background>
					<Border.BorderBrush>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FF3B2C31" Offset="0"/>
							<GradientStop Color="#FFD9D7E5" Offset="1"/>
						</LinearGradientBrush>
					</Border.BorderBrush>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBlock Margin="0" Text="رقم التعهد" />
						<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding SearchClaimNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
						<Button Content="{DynamicResource FindImage}" Grid.Column="2" Margin="0" d:LayoutOverrides="Height"
							Command="{Binding FindCommand}" ToolTip="( Ctrl + F)"/>
					</Grid>
				</Border>
			</Grid>
        
        <!--Customer Section-->
			<Rectangle Grid.Row="1" Height="2" StrokeThickness="2" Stretch="Fill" Stroke="#FFC8C7C7"/>
			<Grid x:Name="CustomerInfo"  Grid.Row="2">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition/>
					<ColumnDefinition Width="Auto" MinWidth="38.027"/>
				</Grid.ColumnDefinitions>
				<Button Content="إدراج" Grid.Column="2" Margin="0,5,5,5" HorizontalAlignment="Right"
					Command="{Binding ElementName=parentView, Path = AddCustomerCommand}" ToolTip="( Ctrl + F2 )"/>
				<TextBlock Margin="5" TextWrapping="Wrap" Text="إسم المستأجر"/>
				<TextBox x:Name="customerName" Grid.Column="1" Margin="5" Text="{Binding  Path=CustomerName, Mode=OneWay}" MinHeight="30" />
			</Grid>
			<Rectangle Grid.Row="3" Height="2" StrokeThickness="2" Stretch="Fill" Stroke="#FFC8C7C7"/>
        
        <!--Outbox Section-->
			<Grid x:Name="OutboxInfo"  Grid.Row="4" HorizontalAlignment="Left"  >
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<TextBlock Margin="5" Grid.Row="0" TextWrapping="Wrap" Text="رقم الصادر"/>
				<TextBlock Margin="5" Grid.Row="1" TextWrapping="Wrap" Text="تاريخ التعهد"/>
            <wpfExtended:MaskedTextBox Grid.Column="1" Margin="5,5,0,5" Grid.Row="0" IncludeLiterals="False" Mask="####/ #### /ج"
										   Value="{Binding OutboxNo, Converter={StaticResource OutboxConverter}}" Width="150" HorizontalAlignment="Left" MinHeight="30"/>
            <wpfExtended:MaskedTextBox Grid.Column="1" Grid.Row="1" IncludeLiterals="False" Mask="##/ ## / ####"
										   HorizontalAlignment="Left" Margin="5,5,0,5" 
										   Value="{Binding OutboxDate, Converter={StaticResource DateConverter}}" Width="150" MinHeight="30"/>
            <CheckBox Content=" ترقيم تلقائي من هذا الرقم" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Left" Name="checkBox1" VerticalAlignment="Top" 
				  IsChecked="{Binding Path=AutoIncrementOutboxNo, UpdateSourceTrigger=PropertyChanged}" IsThreeState="False" Margin="8" TabIndex="2" BorderThickness="1"/>
        </Grid>
			<Rectangle Grid.Row="5" Height="2" StrokeThickness="2" Stretch="Fill" Stroke="#FFC8C7C7"/>
        
        <!--ClaimInof Section-->
			<Grid x:Name="ClaimInfo" Grid.Row="6">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="*"/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				<TextBlock Margin="5" TextWrapping="Wrap" Text="رقم المطالبة"/>
				<TextBlock Margin="5" Grid.Row="1" TextWrapping="Wrap" Text="ملاحظة 1"/>
				<TextBlock Margin="5" Grid.Row="2" TextWrapping="Wrap" Text="ملاحظة 2"/>
				<TextBox Grid.Column="1" Margin="5" Text="{Binding ClaimNo, UpdateSourceTrigger=PropertyChanged}" Width="150" MinHeight="30" HorizontalAlignment="Left"/>
				<TextBox Grid.Column="1" Margin="5" Grid.Row="1" Text="{Binding CaptionText1, UpdateSourceTrigger=PropertyChanged}" MinHeight="30"/>
				<TextBox Grid.Column="1" Margin="5" Grid.Row="2" Text="{Binding CaptionText2, UpdateSourceTrigger=PropertyChanged}" MinHeight="30" />
			</Grid>
       
        <!--Claim Details Section -->
			<Rectangle Grid.Row="7" Height="2" StrokeThickness="2" Stretch="Fill" Stroke="#FFC8C7C7"/>
			<Grid x:Name="DetailsInfo" Grid.Row="8" >
				<Grid.ColumnDefinitions>
					<ColumnDefinition/>
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition/>
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Button Content="إضافة تفاصيل المطالبة" Margin="0,5,5,5" Command="{Binding ElementName=parentView, Path = AddDetailsCommand}" Grid.Column="1" HorizontalAlignment="Right"
					ToolTip="( Ctrl+F4 )"/>
				<Border Grid.ColumnSpan="2" Margin="5" MinHeight="100" Grid.Row="1" BorderThickness="1" CornerRadius="2" BorderBrush="Silver" Padding="2" >
					<DataGrid x:Name="dgClaimDetails" ItemsSource="{Binding ClaimDetails}"
							  AutoGenerateColumns="False" CanUserAddRows="False" CanUserSortColumns="False" CanUserReorderColumns="False" RowHeaderWidth="20" SelectionChanged="ClaimDetailSelectionChanged"
							  SelectionMode="Single" SelectionUnit="FullRow" ContextMenu="{StaticResource gridRowContextMenu}" >
						<DataGrid.Columns>
							<DataGridTextColumn Header="الربط المستحق" Binding="{Binding Rent}" />
							<DataGridTextColumn Header="المسدد" Binding="{Binding RentPaid}"/>
							<DataGridTextColumn Header="رقم وموقع العين" Binding="{Binding Property.Description}" IsReadOnly="True" Width="Auto"/>
							<DataGridTextColumn Header="الصيانة" Binding="{Binding Maintenance}"/>
							<DataGridTextColumn Header="التأمين" Binding="{Binding Deposit}"/>
							<DataGridTextColumn Header="أخرى" Binding="{Binding Other}"/>
							<DataGridTextColumn Header="المتبقي" Binding="{Binding RentBalance}"/>
							<DataGridTextColumn Header="إيجار متأخر" Binding="{Binding ArrearRent}"/>
							<DataGridTextColumn Header="صيانة متأخرة" Binding="{Binding ArrearMaintenance}"/>
							<DataGridTextColumn Header="الإجمالي" Binding="{Binding Total}"/>
						</DataGrid.Columns>
					<DataGrid.RowHeaderStyle>
						<Style TargetType="DataGridRowHeader" BasedOn="{StaticResource {x:Type DataGridRowHeader}}">
							<Setter Property="ContextMenu" Value="{StaticResource gridRowContextMenu}"/>
						</Style>
					</DataGrid.RowHeaderStyle>
				</DataGrid>
				</Border>
				<TextBlock HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="2" TextWrapping="Wrap" Text="المجموع" />
				<TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="4.999,5,0,5" Grid.Row="2" TextWrapping="Wrap" 
					Text="{Binding CalimTotal}" />
			</Grid>
			
		</Grid>

</UserControl>
